#pragma once
#include "stdafx.h"
#include "FbxScene.h"
#include "FbxSdkManager.h"
#include "FbxNode.h"
#include "FbxGenericNode.h"
#include "FbxCharacter.h"
#include "FbxCharacterPose.h"
#include "FbxControlSet.h"
#include "FbxPose.h"
#include "FbxSurfaceMaterial.h"
#include "FbxGlobalLightSettings.h"
#include "FbxGlobalCameraSettings.h"
#include "FbxGlobalTimeSettings.h"
#include "FbxGlobalSettings.h"
#include "FbxTexture.h"
#include "FbxGeometry.h"
#include "FbxVideo.h"
#include "FbxString.h"
#include "FbxDocumentInfo.h"
#include "FbxTakeNodeContainer.h"
#include "FbxClassId.h"

namespace Skill
{
	namespace FbxSDK
	{	


		void FbxScene::CollectManagedMemory()
		{
			_GlobalCameraSettings = nullptr;
			_GlobalLightSettings = nullptr;
			_GlobalTimeSettings = nullptr;
			_GlobalSettings = nullptr;
			_RootNode = nullptr;
			_SceneInfo = nullptr;
			FbxDocument::CollectManagedMemory();
		}

		FBXOBJECT_DEFINITION(FbxScene,KFbxScene);

		void FbxScene::Clear()
		{
			_Ref()->Clear();
		}
		REF_PROPERTY_GET_DEFINATION_FROM_REF(FbxScene,KFbxNode,GetRootNode(),FbxNode,RootNode);		
		int FbxScene::GenericNodeCount::get()
		{
			return _Ref()->GetGenericNodeCount();
		}			
		FbxGenericNode^ FbxScene::GetGenericNode(int index)
		{
			KFbxGenericNode* node = _Ref()->GetGenericNode(index);
			if(node)
				return gcnew FbxGenericNode(node);
			return nullptr;
		}
		FbxGenericNode^ FbxScene::GetGenericNode(String^ name)
		{			
			STRINGTOCHAR_ANSI(n,name);
			FbxGenericNode^ g = gcnew FbxGenericNode(_Ref()->GetGenericNode(n));
			FREECHARPOINTER(n);
			return g;
		}
		bool FbxScene::AddGenericNode(FbxGenericNode^ genericNode)
		{
			return _Ref()->AddGenericNode(genericNode->_Ref());
		}
		bool FbxScene::RemoveGenericNode(FbxGenericNode^ genericNode)
		{
			return _Ref()->RemoveGenericNode(genericNode->_Ref());
		}
		int FbxScene::CharacterCount::get()
		{
			return _Ref()->GetCharacterCount();
		}			
		FbxCharacter^ FbxScene::GetCharacter(int index)
		{
			return gcnew FbxCharacter(_Ref()->GetCharacter(index));
		}
		int FbxScene::GetCharacter(String^ name)
		{			
			STRINGTOCHAR_ANSI(n,name);
			int r = _Ref()->CreateCharacter(n);
			FREECHARPOINTER(n);
			return r;
		}
		void FbxScene::DestroyCharacter(int index)
		{
			_Ref()->DestroyCharacter(index);
		}
		int FbxScene::ControlSetPlugCount::get()
		{
			return _Ref()->GetControlSetPlugCount();
		}			
		FbxControlSetPlug^ FbxScene::GetControlSetPlug(int index)
		{
			return gcnew FbxControlSetPlug(_Ref()->GetControlSetPlug(index));
		}
		int FbxScene::CreateControlSetPlug(String^ name)
		{			
			STRINGTOCHAR_ANSI(n,name);
			int r =_Ref()->CreateControlSetPlug(n);
			FREECHARPOINTER(n);
			return r;
		}
		void FbxScene::DestroyControlSetPlug(int index)
		{
			_Ref()->DestroyControlSetPlug(index);
		}
		int FbxScene::CharacterPoseCount::get()
		{
			return _Ref()->GetCharacterPoseCount();
		}

		FbxCharacterPose^ FbxScene::GetCharacterPose(int index)
		{
			return gcnew FbxCharacterPose(_Ref()->GetCharacterPose(index));
		}
		int FbxScene::CreateCharacterPose(String^ name)
		{			
			STRINGTOCHAR_ANSI(n,name);
			int r = _Ref()->CreateCharacterPose(n);
			FREECHARPOINTER(n);
			return r;
		}
		void FbxScene::DestroyCharacterPose(int index)
		{
			_Ref()->DestroyCharacterPose(index);
		}
		int FbxScene::PoseCount::get()
		{
			return _Ref()->GetPoseCount();
		}			
		FbxPose^ FbxScene::GetPose(int index)
		{
			return gcnew FbxPose(_Ref()->GetPose(index));
		}
		bool FbxScene::AddPose(FbxPose^ pose)
		{
			return _Ref()->AddPose(pose->_Ref());
		}
		bool FbxScene::RemovePose(FbxPose^ pose)
		{
			return _Ref()->RemovePose(pose->_Ref());
		}
		bool FbxScene::RemovePose(int index)
		{
			return _Ref()->RemovePose(index);
		}

		REF_PROPERTY_GET_DEFINATION_FROM_REF(FbxScene,KFbxDocumentInfo,GetSceneInfo(),FbxDocumentInfo,SceneInfo);
		REF_PROPERTY_SET_DEFINATION_BY_FUNC(FbxScene,SetSceneInfo,FbxDocumentInfo,SceneInfo);		

		REF_PROPERTY_GET_DEFINATION_FROM_VALUE(FbxScene,GetGlobalSettings(),FbxGlobalSettings,GlobalSettings);
		REF_PROPERTY_GET_DEFINATION_FROM_VALUE(FbxScene,GetGlobalLightSettings(),FbxGlobalLightSettings,GlobalLightSettings);
		REF_PROPERTY_GET_DEFINATION_FROM_VALUE(FbxScene,GetGlobalCameraSettings(),FbxGlobalCameraSettings,GlobalCameraSettings);
		REF_PROPERTY_GET_DEFINATION_FROM_VALUE(FbxScene,GetGlobalTimeSettings(),FbxGlobalTimeSettings,GlobalTimeSettings);

#ifndef DOXYGEN_SHOULD_SKIP_THIS

		void FbxScene::ConnectMaterials()
		{
			_Ref()->ConnectMaterials();
		}

		void FbxScene::BuildMaterialLayersDirectArray()
		{
			_Ref()->BuildMaterialLayersDirectArray();
		}

		void FbxScene::ReindexMaterialConnections()
		{
			_Ref()->ReindexMaterialConnections();
		}
		CLONE_DEFINITION(FbxScene,KFbxScene);
		int FbxScene::MaterialCount::get()
		{
			return _Ref()->GetMaterialCount();
		}

		FbxSurfaceMaterial^ FbxScene::GetMaterial (int index)
		{
			return FbxCreator::CreateFbxSurfaceMaterial(_Ref()->GetMaterial (index));
		}
		FbxSurfaceMaterial^ FbxScene::GetMaterial (String^ name)
		{			
			STRINGTOCHAR_ANSI(n,name);
			FbxSurfaceMaterial^ sm= FbxCreator::CreateFbxSurfaceMaterial(_Ref()->GetMaterial(n));
			FREECHARPOINTER(n);
			return sm;

		}
		bool FbxScene::AddMaterial (FbxSurfaceMaterial^ material)
		{
			return _Ref()->AddMaterial(material->_Ref());
		}
		bool FbxScene::RemoveMaterial (FbxSurfaceMaterial^ material)
		{
			return _Ref()->RemoveMaterial(material->_Ref());
		}			
		int FbxScene::TextureCount::get()
		{
			return _Ref()->GetTextureCount();
		}			
		FbxTexture^ FbxScene::GetTexture(int index)
		{
			return FbxCreator::CreateFbxTexture(_Ref()->GetTexture(index));
		}
		FbxTexture^ FbxScene::GetTexture(String^ name)
		{			
			STRINGTOCHAR_ANSI(n,name);
			FbxTexture^ t = FbxCreator::CreateFbxTexture(_Ref()->GetTexture(n));
			FREECHARPOINTER(n);
			return t;
		}
		bool FbxScene::AddTexture (FbxTexture^texture)
		{
			return _Ref()->AddTexture(texture->_Ref());
		}
		bool FbxScene::RemoveTexture(FbxTexture^ texture)
		{
			return _Ref()->RemoveTexture(texture->_Ref());
		}			
		int FbxScene::NodeCount::get()
		{
			return _Ref()->GetNodeCount();
		}			
		FbxNode^ FbxScene::GetNode (int index)
		{
			return gcnew FbxNode(_Ref()->GetNode(index));
		}			
		bool FbxScene::AddNode (FbxNode^node)
		{
			return _Ref()->AddNode(node->_Ref());
		}
		bool FbxScene::RemoveNode (FbxNode^ node)
		{
			return _Ref()->RemoveNode(node->_Ref());
		}			
		int FbxScene::CurveOnSurfaceCount::get()
		{
			return _Ref()->GetCurveOnSurfaceCount();
		}			
		FbxNode^ FbxScene::FindNodeByName (FbxString^ name)
		{
			KFbxNode* node =_Ref()->FindNodeByName(*name->_Ref());
			if(node)
			{
				return gcnew FbxNode(node);
			}
			return nullptr;
		}			
		int FbxScene::GeometryCount::get()
		{
			return _Ref()->GetGeometryCount();
		}			
		FbxGeometry^ FbxScene::GetGeometry(int index)
		{
			KFbxGeometry* g = _Ref()->GetGeometry(index);
			if(g)
				return FbxCreator::CreateFbxGeometry(g);
			return nullptr;
		}
		bool FbxScene::AddGeometry(FbxGeometry^ geometry)
		{
			return _Ref()->AddGeometry(geometry->_Ref());
		}
		bool FbxScene::RemoveGeometry(FbxGeometry^ geometry)
		{
			return _Ref()->RemoveGeometry(geometry->_Ref());
		}
		int FbxScene::VideoCount::get()
		{
			return _Ref()->GetVideoCount();
		}

		FbxVideo^ FbxScene::GetVideo (int index)
		{
			return gcnew FbxVideo(_Ref()->GetVideo(index));
		}
		bool FbxScene::AddVideo (FbxVideo^ video)
		{
			return _Ref()->AddVideo(video->_Ref());
		}
		bool FbxScene::RemoveVideo(FbxVideo^ video)
		{
			return _Ref()->RemoveVideo(video->_Ref());
		}
		int FbxScene::TakeNodeContainerCount::get()
		{
			return _Ref()->GetTakeNodeContainerCount();
		}			
		FbxTakeNodeContainer^  FbxScene::GetTakeNodeContainer(int index)
		{
			KFbxTakeNodeContainer* n = _Ref()->GetTakeNodeContainer(index);
			if(n)
				return FbxCreator::CreateFbxTakeNodeContainer(n);
			return nullptr;
		}
		bool FbxScene::AddTakeNodeContainer(FbxTakeNodeContainer^takeNodeContainer)
		{
			return _Ref()->AddTakeNodeContainer(takeNodeContainer->_Ref());
		}
		bool FbxScene::RemoveTakeNodeContainer(FbxTakeNodeContainer^ takeNodeContainer)
		{
			return _Ref()->RemoveTakeNodeContainer(takeNodeContainer->_Ref());
		}
		void FbxScene::ConvertNurbsSurfaceToNurb()
		{
			_Ref()->ConvertNurbsSurfaceToNurb();
		}
		void FbxScene::ConvertMeshNormals()
		{
			_Ref()->ConvertMeshNormals();
		}
		void FbxScene::ConvertNurbCurvesToNulls()
		{
			_Ref()->ConvertNurbCurvesToNulls();
		}

#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS		

	}
}